#!/usr/env/bin python
# -*- coding: utf-8 -*-

# @Time    : 2020-08-24 10:48 上午
# @Author  : yangdy
# @File    : 2020-08-22.3.1558.得到目标数组的最少函数调用次数
# @Software: PyCharmCE
from tools.my_methods import *


class Solution:
    def minOperations(self, nums: List[int]) -> int:
        ans = 0
        m = 0
        for i in nums:
            if i > m:
                m = i
            while i:
                if i % 2 == 1:
                    ans += 1
                i //= 2
        while m > 0:
            ans += 1
            m //= 2
        return ans-1